﻿Imports Relatorio
Imports Persistencia
Imports System.IO
Public Class frmPrincipal
    Inherits System.Windows.Forms.Form
    Public objUsuario As New perUsuario

    Private Sub PessoaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PessoaToolStripMenuItem.Click
        Dim frm As New frmCliente
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub EstadoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EstadoToolStripMenuItem.Click
        Dim frm As New frmEstado
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub CidadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CidadeToolStripMenuItem.Click
        Dim frm As New frmCidade
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub BairroToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BairroToolStripMenuItem.Click
        Dim frm As New frmBairro
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub RegiãoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegiãoToolStripMenuItem.Click
        Dim frm As New frmRegiao
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub StatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusToolStripMenuItem.Click
        Dim frm As New frmStatus
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub DepartamentoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DepartamentoToolStripMenuItem.Click
        Dim frm As New frmDepartamento
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub ClientesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClientesToolStripMenuItem.Click
        Dim frm As New frmRelClientes
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub frmPrincipal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim objSeguranca As New Persistencia.perSeguranca
        Dim sStringConexao As String = "\SQL.DC"
        Dim sLocalExecutaval As String
        Dim ftmConexao As New frmConexao
        Dim frmTarefa As New frmTarefas
        sLocalExecutaval = Application.StartupPath

        If Not (IO.File.Exists(sLocalExecutaval + sStringConexao)) Then
            Me.Visible = False
            With frmConexao
                .ShowDialog()
                If (.DialogResult = Windows.Forms.DialogResult.OK) Then
                    Me.Visible = True
                Else
                    Application.Exit()
                    Exit Sub
                End If
            End With
        End If

        If (objUsuario.Usuario = 0) Then
            With frmAcesso
                Me.Visible = False
                .ShowDialog()
                If (.DialogResult = Windows.Forms.DialogResult.OK) Then
                    objUsuario.Usuario = .Usuario
                    Me.Visible = True
                    frmTarefa.MdiParent = Me
                    frmTarefa.Show()
                End If
            End With
        End If
    End Sub

    Private Sub OcorrênciasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OcorrênciasToolStripMenuItem.Click

    End Sub

    Private Sub OcorrênciasToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OcorrênciasToolStripMenuItem1.Click
        Dim frm As New frmOcorrencia
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

    End Sub

    Private Sub CadastroToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CadastroToolStripMenuItem.Click
        Dim frmUsu As New frmUsuario
        frmUsu.Show()
    End Sub

    Private Sub ToolStripStatusLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TarefasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TarefasToolStripMenuItem.Click

        frmTarefas.MdiParent = Me
        frmTarefas.Show()

    End Sub

    Private Sub ContatosRealizadosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContatosRealizadosToolStripMenuItem.Click

        frmRelContatosRealizados.MdiParent = Me
        frmRelContatosRealizados.Show()

    End Sub

    Private Sub ContatosARealizarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContatosARealizarToolStripMenuItem.Click
        frmContatosARealizar.MdiParent = Me
        frmContatosARealizar.Show()
    End Sub

    Private Sub SairToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem.Click
        Application.Exit()
    End Sub

    Private Sub FerramentasDoSistemaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FerramentasDoSistemaToolStripMenuItem.Click
        frmFerramentas.ShowDialog()
    End Sub
End Class